#ifndef PROPERTIES_H
#define PROPERTIES_H

#include <list>
#include <vector>
#include <sstream>
#include <fstream>
#include <iostream>

#include "Hotel.h"
#include "MailBox.h"
#include "Consultant.h"
#include "rapidxml_print.hpp"

class Properties{
public :
	static const std::string PROPS_FILE;
	static const std::string ROOT_NODE;
	static const std::string HOTELS_NODE;
	static const std::string CONSULTANTS_NODE;

private :
	MailBox* mailBox;
	std::list<Hotel*>* hotels;
	std::list<Consultant*>* consultants;

	Properties(const Properties&){}

	void loadMailBox(rapidxml::xml_node<>* mBoxNode);
	void loadHotels(rapidxml::xml_node<>* hotelsNode);
	void loadConsultants(rapidxml::xml_node<>* consultantsNode);

public :
	Properties(void) : mailBox(0) {
		hotels = new std::list<Hotel*>();
		consultants = new std::list<Consultant*>();
	}

	virtual ~Properties(void){
		
		delete(mailBox);
		
		if(hotels){
			hotels->clear();
		}

		delete(hotels);

		if(consultants){
			consultants->clear();
		}

		delete(consultants);
	}

	void setMailBox(MailBox* _mailBox){

		if(mailBox && mailBox != _mailBox){
			delete(mailBox);
		}

		mailBox = _mailBox;
	}

	void addHotel(Hotel* hotel){
		hotels->push_front(hotel);
	}

	void addConsultant(Consultant* consultant){
		consultants->push_front(consultant);
	}

	MailBox* getMailBox() const { return mailBox; }
	std::list<Hotel*>* getHotels(void) const { return hotels; }
	std::list<Consultant*>* getConsultants(void) const { return consultants; }

	void loadProperties(void);
	void saveProperties(void);
};

#endif //PROPERTIES_H